﻿#include "eventfragment.h"
#include "ui_eventfragment.h"
#include "editeventfragment.h"
EventFragment::EventFragment(Event event,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::EventFragment) {
    ui->setupUi(this);
    this->event = event;
    ui->label_event_name->setText(event.getName());
    ui->label_event_time->setText(event.getTime().toString("HH:mm:ss"));
    ui->textEdit_description->setText(event.getDescription());
    QVector<QString> names = event.getPeople();
    for(auto &name:names)ui->listWidget_people->addItem(name);
}

EventFragment::~EventFragment() {
    delete ui;
}

bool EventFragment::chosen() {
    return ui->checkBox_chosen->isChecked();
}

void EventFragment::on_pushButton_clicked()
{
    Event eve = EditEventFragment::getEvent(this->event);
    emit onEventChange(eve);
}
